package jtk.project4.fleet.field;
/*
* Author : Sherman Firdaus
* Date Created : 31-Maret-2011
* Date Modified : 5-April-2011
* Version : 1.1
* */

import java.text.SimpleDateFormat;

import jtk.project4.fleet.domain.Equipment;


import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormLayout.Resize;
import nl.coderight.jazz.form.control.CalendarControl;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.MemoField;
import nl.coderight.jazz.form.field.NumberField;
import nl.coderight.jazz.form.field.SelectField;
import nl.coderight.jazz.form.field.TextField;
import nl.coderight.jazz.form.field.button.PushButton;


public class EquipmentInsurancePolicyInformationField extends GroupControl<Equipment> {
	private SelectField companyField;
	private MemoField companyInfoField;
	private TextField policyField;
	private CalendarControl startDateField;
	private CalendarControl endDateField;
	private NumberField paymentField;
	private NumberField deductibleField;
	private TextField notesField;
	
	
	public EquipmentInsurancePolicyInformationField(String bindID) {
		setTitle("header.equipmentInsurance");
		setBindID(bindID);
		createFields();
		createLayout();
	}
	
	private void createFields(){
		policyField = new TextField("Policy#", 20);
		
		companyField = new SelectField("Equipments","Company");
		companyField.setPreferredSize(policyField.getPreferredSize());
		
		companyInfoField = new MemoField("Company Info");
		companyInfoField.setRows(4);
		companyInfoField.setEditable(false);
		//companyInfoField.setPreferredSize(policyField.getPreferredSize());		
		
		startDateField = new CalendarControl("Start Date", 0);
		startDateField.setFormat(new SimpleDateFormat(translate("MM/dd/yyyy")));
		startDateField.showYearSpinner(true);

		endDateField = new CalendarControl("End Date", 0);
		endDateField.setFormat(new SimpleDateFormat(translate("MM/dd/yyyy")));
		endDateField.showYearSpinner(true);		
		
		startDateField.setPreferredSize(policyField.getPreferredSize());
		endDateField.setPreferredSize(policyField.getPreferredSize());
		
		paymentField = new NumberField("Payment",10);
		paymentField.setRequired(true);
		
		deductibleField = new NumberField("Deductible",10);
		deductibleField.setRequired(true);
		
		notesField = new TextField("Notes",20);
		
		
		}
	
	
	private void createLayout() {
		setLayout(new FormLayout())
		.addLabel("Company")	.addField(companyField)
		.addRow()
		.addLabel("")			.addField(companyInfoField)
		.addRow()
		.addLabel("Policy#")	.addField(policyField)
		.addLabel("Payment")	.addField(paymentField)
		.addRow()
		.addLabel("Start Date")	.addField(startDateField)
		.addLabel("Deductible")	.addField(deductibleField)
		.addRow()
		.addLabel("End Date")	.addField(endDateField)
		.addLabel("Notes")		.addField(notesField)
		;
	
	}
	
}

	
	
